package nettydemo;/*

 */

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.zip.Inflater;

/**
 * @ClassName TransferFromDemo
 * @Author Final
 * @Project DataStructures
 *
 * 使用TransferFrom完成文件copy
 */
public class TransferFromDemo {

    public static void main(String[] args) throws IOException {

        FileInputStream fileInputStream=new FileInputStream("1.txt");
        FileChannel channel = fileInputStream.getChannel();

        FileOutputStream fileOutputStream=new FileOutputStream("3.txt");
        FileChannel channel1 = fileOutputStream.getChannel();

        channel1.transferFrom(channel,0,channel.size());

        channel.close();
        channel1.close();
        fileInputStream.close();
        fileOutputStream.close();
    }
}
